﻿using Apps.Models;
using Apps.Models.PUB;
using System;
using System.Linq;

namespace Apps.DAL.PUB
{    public partial class PUB_MATERIELRepository
    {
        public IQueryable<PUB_MATERIEL> GetListBySupplierId(string SupplierId)
        {
            IQueryable<PUB_MATERIEL> list = from a in Context.PUB_MATERIEL
                                                 join b in Context.PUB_SUPPLIERMETERIEL on a.MATERIEL_ID equals b.MATERIEL_ID
                                             where b.SUPPLIER_ID == SupplierId
                                                 select a;
            return list;
        }

        public IQueryable<PUB_MATERIEL> GetListNotINSupplierId(string SupplierId)
        {
            IQueryable<PUB_MATERIEL> list = from a in Context.PUB_MATERIEL 
                                            where !(from b in Context.PUB_SUPPLIERMETERIEL  where b.SUPPLIER_ID == SupplierId select b.MATERIEL_ID).Contains(a.MATERIEL_ID)                                            
                                            select a;
            return list;
        }
    }
}
